{m:include "member","header"}
<div class="yzm_member_container main">
    {m:include "member","left"}
    <div class="main_right">
        <div class="tit">
            <h3>发信息</h3>
        </div>
        <div class="main_cont">
            <form method="post" action="" onsubmit="return chcekall()">
                <table>
                    <tr>
                        <td><span class="required">*</span>收信人：</td>
                        <td>
                        	<input type="text" name="send_to" value="{if isset($data['send_from'])}{$data['send_from']}{/if}" id="username" required class="input">
                        </td>
                    </tr>
                    <tr>
                        <td><span class="required">*</span>标 题：</td>
                        <td>
                        	<input type="text" name="subject" required value="{if isset($data['subject'])}{$data['subject']}{/if}" class="input">
                        </td>
                    </tr>
                    <tr>
                        <td><span class="required">*</span>内 容：</td>
                        <td>
                        	<textarea name="content" class="textarea" required></textarea>
                        </td>
                    </tr>
                    <tr>
                        <td><span class="required">*</span>验证码：</td>
                        <td> 
                        	<input type="text" class="input" required name="code" id="code" style="width:150px;"><img src="{U('api/index/code')}" onclick="this.src=this.src+'?'" class="yzm-code-img" title="看不清，换一张">
                        </td>
                    </tr>
                    <tr>
                        <td></td>
                        <td>
                        	<input type="submit" name="dosubmit" id="dosubmit" class="submit" value="提交">
                        </td>
                    </tr>
                </table>
            </form>
        </div>
    </div>
</div>
<script type="text/javascript">
	$(function() {
	    $("#username").blur(function() {
	        checkname();
	    });
	})
	function checkname(){
		var res = false;
		if($("#username").val() != ''){
			$.ajax({   
				type: "post",   
				url: "{U('member/index/public_checkname')}",   
				dataType: "html",
				async: false,	
				data: "username="+$('#username').val(), 			
				success: function(msg){  
				if(msg == '-1'){
					res = true;				  
				}else if(msg == '1'){
					layer.msg('用户名不存在！', {icon:2, time:2000});		  
				}else if(msg == '0'){
					layer.msg('用户名格式不正确！', {icon:2, time:2000});		  
				}else{
					layer.msg('未知错误！', {icon:2, time:2000});			  
				}				 
				} 
			});
			return res;
		}else{
			layer.msg('用户名不能为空！', {icon:2, time:2000});
			return res;
		}		   
	}

	function chcekall(){
	    if(!checkname()){
	    	return false;
	    }
		if($(".error").text()) return false;
		if($("input[name='subject']").val()==''){
		  layer.msg('标题不能为空！', {icon:2, time:2000});
		  return false;
		}
		if($("input[name='content']").val()==''){
		  layer.msg('内容不能为空！', {icon:2, time:2000});
		  return false;
		}
		if($("input[name='code']").val()==''){
		  layer.msg('验证码不能为空！', {icon:2, time:2000});
		  return false;
		}	
	}
</script>
{m:include "member","footer"}